.code-viewer-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
  background-color: #ffffff;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', sans-serif;
}

// 头部信息栏
.header-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 24px;
  background: #f8f9fa;
  border-bottom: 1px solid #e9ecef;
  flex-shrink: 0;

  .file-info {
    display: flex;
    flex-direction: column;
    gap: 4px;

    .file-title {
      margin: 0;
      font-size: 20px;
      font-weight: 600;
      color: #333;
    }

    .file-details {
      font-size: 14px;
      color: #666;
    }

    .syntax-support {
      font-size: 12px;
      color: #28a745;
      font-weight: 500;
    }
  }

  .actions {
    display: flex;
    gap: 12px;
    align-items: center;
  }
}

// 加载状态
.loading-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  padding: 40px;

  .loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #e9ecef;
    border-top: 4px solid #007acc;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 16px;
  }

  p {
    color: #666;
    font-size: 16px;
    margin: 0;
  }
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

// 错误状态
.error-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  padding: 40px;
  text-align: center;

  .error-icon {
    font-size: 48px;
    margin-bottom: 16px;
  }

  .error-message {
    color: #dc3545;
    font-size: 16px;
    margin-bottom: 24px;
    max-width: 400px;
  }
}

// 主内容区域
.main-content {
  display: flex;
  flex: 1;
  overflow: hidden;
}

// 区域信息面板
.regions-panel {
  width: 260px;
  background: #f8f9fa;
  border-right: 1px solid #e9ecef;
  padding: 20px;
  overflow-y: auto;
  flex-shrink: 0;

  h3 {
    margin: 0 0 16px 0;
    font-size: 16px;
    font-weight: 600;
    color: #333;
  }

  h4 {
    margin: 20px 0 12px 0;
    font-size: 14px;
    font-weight: 600;
    color: #333;
  }

  .regions-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 24px;
  }

  .region-item {
    background: #ffffff;
    border: 1px solid #e9ecef;
    border-radius: 6px;
    padding: 12px;
    transition: all 0.2s ease;

    &:hover {
      box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
      border-color: #007acc;
    }

    .region-info {
      display: flex;
      flex-direction: column;
      gap: 4px;
      margin-bottom: 8px;

      .region-name {
        font-weight: 500;
        color: #333;
        font-size: 14px;
      }

      .region-lines {
        font-size: 12px;
        color: #666;
      }
    }

    .region-status {
      display: flex;
      justify-content: flex-end;

      .status-badge {
        background: #d4edda;
        color: #155724;
        padding: 2px 8px;
        border-radius: 12px;
        font-size: 11px;
        font-weight: 500;
        border: 1px solid rgba(0, 0, 0, 0.1);
      }
    }
  }

  .quick-actions {
    border-top: 1px solid #e9ecef;
    padding-top: 16px;
    margin-bottom: 20px;

    .btn-action {
      display: block;
      width: 100%;
      padding: 8px 12px;
      margin-bottom: 8px;
      background: #ffffff;
      border: 1px solid #007acc;
      color: #007acc;
      border-radius: 4px;
      cursor: pointer;
      font-size: 13px;
      font-weight: 500;
      transition: all 0.2s;

      &:hover {
        background: #007acc;
        color: white;
      }

      &:last-child {
        margin-bottom: 0;
      }
    }
  }

  // 语法高亮信息面板
  .syntax-info {
    border-top: 1px solid #e9ecef;
    padding-top: 16px;

    .syntax-status {
      display: flex;
      flex-direction: column;
      gap: 8px;

      .language-tag {
        display: inline-block;
        background: #007acc;
        color: white;
        padding: 2px 8px;
        border-radius: 12px;
        font-size: 11px;
        font-weight: 600;
        text-align: center;
      }

      .support-status {
        font-size: 12px;
        font-weight: 500;

        &.supported {
          color: #28a745;
        }

        &.not-supported {
          color: #dc3545;
        }
      }
    }
  }
}

// 编辑器容器
.editor-container {
  display: flex;
  flex-direction: column;
  flex: 1;
  overflow: hidden;

  .editor-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: #f1f3f4;
    border-bottom: 1px solid #e9ecef;
    flex-shrink: 0;
    flex-wrap: wrap;
    gap: 12px;

    .editor-title {
      font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
      font-size: 14px;
      font-weight: 500;
      color: #333;
    }

    .editor-language {
      font-size: 12px;
      color: #666;
      background: #e9ecef;
      padding: 2px 8px;
      border-radius: 12px;
    }

    .editor-mode-indicator {
      display: flex;
      align-items: center;
      gap: 6px;
      font-size: 12px;

      .mode-label {
        color: #666;
        font-weight: 500;
      }

      .mode-name {
        padding: 2px 8px;
        border-radius: 12px;
        font-weight: 600;

        &.monaco {
          background: #007acc;
          color: white;
        }

        &.custom {
          background: #28a745;
          color: white;
        }
      }
    }
  }

  // 自定义代码显示区域
  .code-display-container {
    flex: 1;
    overflow-y: auto;
    background: #ffffff;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', 'Consolas', monospace;
    font-size: 14px;
    line-height: 1.5;

    .line-container {
      display: flex;
      align-items: flex-start;
      min-height: 21px;
      border-left: 3px solid transparent;

      &:hover {
        // 悬停效果需要考虑背景色
        .code-line:not(.original-visible) {
          background-color: #f8f9fa;
        }
        .code-line.original-visible {
          filter: brightness(0.95);
        }
      }
    }

    // 普通代码行
    .code-line {
      display: flex;
      width: 100%;
      align-items: flex-start;
      transition: all 0.2s ease;

      .line-number {
        flex-shrink: 0;
        width: 60px;
        padding: 0 16px 0 12px;
        color: #666;
        text-align: right;
        font-size: 12px;
        border-right: 1px solid #e9ecef;
        line-height: 21px;
        background: inherit; // 继承父元素背景色
      }

      .line-content {
        flex: 1;
        margin: 0;
        padding: 0 16px;
        white-space: pre;
        word-wrap: break-word;
        overflow-x: auto;
        font-family: inherit;
        font-size: inherit;
        line-height: inherit;
        color: #333;
        background: inherit; // 继承父元素背景色

        // 语法高亮的tokens样式 - 确保Prism.js样式生效
        :global(.token) {
          &.comment {
            color: #6a9955 !important;
            font-style: italic;
          }
          
          &.keyword {
            color: #0000ff !important;
            font-weight: bold;
          }
          
          &.string {
            color: #a31515 !important;
          }
          
          &.number {
            color: #098658 !important;
          }
          
          &.function {
            color: #795e26 !important;
          }
          
          &.class-name {
            color: #267f99 !important;
          }
          
          &.operator {
            color: #000000 !important;
          }
          
          &.punctuation {
            color: #0000ff !important;
          }
          
          &.property {
            color: #005cc5 !important;
          }
          
          &.selector {
            color: #22863a !important;
          }
        }
      }

      // 原始可见区域样式
      &.original-visible {
        position: relative;
        
        &::before {
          content: '';
          position: absolute;
          left: 0;
          top: 0;
          bottom: 0;
          width: 3px;
          background: linear-gradient(180deg, #007acc, #0056b3);
        }

        .line-number {
          background: rgba(255, 255, 255, 0.8);
          backdrop-filter: blur(1px);
        }
      }

      // 手动展开区域样式
      &.manually-expanded {
        background: transparent !important;
        position: relative;

        &::before {
          content: '';
          position: absolute;
          left: 0;
          top: 0;
          bottom: 0;
          width: 3px;
          background: #dee2e6;
        }

        .line-number {
          background: #f8f9fa;
          color: #888;
        }

        .line-content {
          color: #555;

          // 手动展开区域的语法高亮颜色稍微淡一些
          .token {
            opacity: 0.8;
          }
        }
      }
    }

    // 折叠占位符行
    .collapsed-line {
      display: flex;
      width: 100%;
      background: transparent;
      margin: 2px 0;
      min-height: 100px; // 适应垂直排列的5行内容
      align-items: stretch;

      // 行号区域带展开按钮 - 垂直排列
      .line-number-expand-area {
        flex-shrink: 0;
        width: 80px;
        display: flex;
        flex-direction: column;
        background: #f8f9fa;
        border-right: 1px solid #e9ecef;
        font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
        font-size: 10px;

        .line-number-item {
          display: flex;
          align-items: center;
          justify-content: center;
          height: 20px;
          border-bottom: 1px solid rgba(0, 0, 0, 0.05);
          transition: all 0.2s ease;

          &.start-line,
          &.end-line {
            color: #666;
            font-weight: 500;
            background: rgba(255, 255, 255, 0.3);
          }

          &.expand-icon {
            cursor: pointer;
            font-weight: bold;
            border-radius: 0;

            &:hover {
              background: rgba(0, 0, 0, 0.1);
              transform: scale(1.2);
            }

            &:active {
              transform: scale(1.0);
            }

            &.expand-up-icon {
              color: #007acc;

              &:hover {
                color: #005a9e;
                background: rgba(0, 122, 204, 0.15);
              }
            }

            &.expand-down-icon {
              color: #007acc;

              &:hover {
                color: #005a9e;
                background: rgba(0, 122, 204, 0.15);
              }
            }

            &.expand-all-icon {
              color: #28a745;
              font-size: 14px;

              &:hover {
                color: #1e7e34;
                background: rgba(40, 167, 69, 0.15);
                transform: scale(1.3);
              }
            }
          }

          &:last-child {
            border-bottom: none;
          }
        }
      }

      .collapsed-content {
        flex: 1;
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 0 16px;

        .collapsed-text {
          color: #999;
          font-style: italic;
          font-size: 12px;
          font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
        }
      }
    }
  }

  // Monaco编辑器样式
  .monaco-editor-wrapper {
    flex: 1;
    overflow: hidden;
    position: relative;
    min-height: 400px;

    &.hidden {
      display: none;
    }
  }

  // Monaco编辑器加载状态
  .monaco-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 400px;
    background: #fafafa;

    .loading-spinner {
      width: 40px;
      height: 40px;
      border: 4px solid #e9ecef;
      border-top: 4px solid #007acc;
      border-radius: 50%;
      animation: spin 1s linear infinite;
      margin-bottom: 16px;
    }

    p {
      color: #666;
      font-size: 14px;
      margin: 0;
    }
  }

  // Monaco编辑器错误提示
  .monaco-error {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: #fff3cd;
    border: 1px solid #ffeaa7;
    border-radius: 6px;
    margin: 12px;

    .error-icon {
      font-size: 24px;
      margin-bottom: 8px;
    }

    p {
      color: #856404;
      margin: 0 0 12px 0;
      text-align: center;
    }
  }
}

// 按钮样式
.btn-small {
  padding: 4px 8px;
  background: #007acc;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 500;
  transition: background-color 0.2s;
  min-width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;

  &:hover {
    background: #005a9e;
  }

  &:active {
    transform: translateY(1px);
  }
}

// 切换按钮样式
.btn-toggle {
  padding: 8px 16px;
  background: #f8f9fa;
  color: #333;
  border: 2px solid #e9ecef;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  gap: 6px;

  &:hover {
    background: #e9ecef;
    border-color: #007acc;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 122, 204, 0.15);
  }

  &.active {
    background: #007acc;
    color: white;
    border-color: #005a9e;
    box-shadow: 0 2px 8px rgba(0, 122, 204, 0.25);
  }

  &:disabled {
    background: #f5f5f5;
    color: #999;
    border-color: #ddd;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
  }
}

// 使用说明
.help-panel {
  background: #f8f9fa;
  border-top: 1px solid #e9ecef;
  padding: 16px 24px;
  flex-shrink: 0;

  details {
    summary {
      cursor: pointer;
      font-weight: 500;
      color: #666;
      font-size: 14px;
      
      &:hover {
        color: #333;
      }
    }

    .help-content {
      margin-top: 12px;
      
      ul {
        margin: 0;
        padding-left: 20px;
        
        li {
          font-size: 14px;
          color: #666;
          line-height: 1.5;
          margin-bottom: 4px;

          strong {
            color: #333;
          }
        }
      }
    }
  }
}

// Monaco Editor 自定义样式
:global {
  .highlighted-line {
    background-color: rgba(0, 122, 204, 0.1) !important;
  }

  .glyph-margin-highlight {
    background-color: #007acc !important;
  }

  .monaco-editor .margin {
    background-color: #f8f9fa !important;
  }

  .monaco-editor .line-numbers {
    color: #666 !important;
  }

  // 折叠行样式
  .monaco-editor .view-line {
    &.folded-line-placeholder {
      color: #999 !important;
      font-style: italic;
      background-color: #f5f5f5 !important;
      cursor: pointer;

      &:hover {
        background-color: #e9ecef !important;
      }
    }
  }
}

// 响应式设计
@media (max-width: 768px) {
  .main-content {
    flex-direction: column;
  }

  .regions-panel {
    width: 100%;
    max-height: 250px;
    border-right: none;
    border-bottom: 1px solid #e9ecef;

    .quick-actions {
      .btn-action {
        display: inline-block;
        width: auto;
        margin-right: 8px;
        margin-bottom: 8px;
      }
    }

    .syntax-info {
      .syntax-status {
        flex-direction: row;
        align-items: center;
        gap: 12px;

        .language-tag {
          margin: 0;
        }
      }
    }
  }

  .header-bar {
    flex-direction: column;
    gap: 12px;
    align-items: stretch;

    .file-info {
      text-align: center;
    }
  }

  .code-display-container {
    .code-line {
      .line-number {
        width: 40px;
        padding: 0 8px 0 8px;
        font-size: 11px;
      }

      .line-content {
        padding: 0 12px;
        font-size: 13px;
      }
    }

    .collapsed-line {
      .line-number-range {
        width: 40px;
        padding: 6px 8px;
        font-size: 10px;
      }

      .collapsed-content {
        padding: 6px 12px;

        .collapsed-text {
          font-size: 12px;
        }

        .expand-actions {
          margin-left: 8px;

          .expand-btn {
            padding: 3px 8px;
            font-size: 11px;
          }
        }
      }
    }
  }
} 